#ifndef DTALBUM_H
#define DTALBUM_H

#include "../abstract/abstractdata.h"
#include <QStringList>
#include <QString>
#include <QDateTime>
#include <QHash>
#include <QDebug>
#include <QSet>
#include <QList>

class DtTrack;
class DtArtist;
class DtGenre;
class DtAlbum : public AbstractData
{
private:
    QString cover;
    int year;
    QList<DtTrack *> lTrack;
    QList<DtArtist *> lArtist;
    QList<DtGenre *> lGenre;
public:
    enum {
        Play = 0,
        Add = 1,
        Name = 2,
        Year = 3,
        Heart = 4,
        Cover = 5,
        NbAttr
    };
    DtAlbum();
    DtAlbum(const QString & name, const int year = -1, const int id = -1,
            const QString & cover = QString::null, const bool heart = false);
    DtAlbum(const DtAlbum &album);
    virtual ~DtAlbum();
    /**
     * @brief operator << is use for the debbugging with Qt. See the Qt Doc to
     *find more help on this function
     * @param dbg the stream of debugging
     * @param genre the genre to show
     * @return
     */
    friend QDebug operator<<(QDebug dbg, const DtAlbum &album);

    /*!
     * \brief Lorsque l'utilisateur clique sur une colonne une action est lancée
     *
     * Méthode de gestion d'action sur le tableau. Elle permet d'effectuer
     *l'action adéquate pour la case
     * \param section : Le numéro de la colonne
     */
    void clicked(const int section);

    /*!
     * \brief
     * \return
     */
    static DtAlbum * findById(QList<DtAlbum> &lAlbum, const int id);

    QList<DtTrack *> &getTracks();
    QList<DtArtist *> &getArtists();
    QList<DtGenre *> &getGenres();

    QString getCovers() const;
    void setCovers(const QString & cover);
    int getYear() const;
    void setYear(const int year);

    void addTrack(DtTrack *track);
    void addGenre(DtGenre *genre);
    void addArtist(DtArtist *artist);
};

/**
 * @brief operator == is use for the QSet container.
 * @param album1
 * @param album2
 * @return
 */
inline bool operator==(const DtAlbum &album1, const DtAlbum &album2)
{
    return (album1.getName().toUpper() == album2.getName().toUpper()
            && album1.getYear() == album2.getYear()
            && album1.getCovers().toUpper() == album2.getCovers().toUpper());
}

/**
 * @brief qHash is use for the QSet container too
 * @param album
 * @return
 */
inline uint qHash(const DtAlbum& album)
{
    return qHash(album.getName().toUpper()) ^ qHash(album.getYear());
}

#endif // DTALBUM_H
